package com.recharge.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.entity.Customer;
import com.entity.Recharge;
import com.file.entity.FileCustomer;
import com.recharge.srevice.OpenAccountService;
import com.utils.JsonResult;

/**
 * @Title: RechargeController.java
 * @Package com.recharge.controller
 * @author 孙梦楠
 * @date 2017年8月22日 下午2:30:55
 * @version V1.0.0
 */
@RestController
@RequestMapping(value = "/recharge")
public class OpenAccountController {

	@Autowired
	private OpenAccountService opencccountservive;

	// 列出所有可开户的总表用户
	@RequestMapping(value = "/list_can_openaccount_customer_total", method = RequestMethod.POST)
	public JsonResult<List<FileCustomer>> listallcustomer_total(@RequestBody Customer customer,
			@CookieValue(value = "opeorgcookie", required = false) String opeorgcookie,
			@CookieValue(value = "opetypecookie", required = false) String opetypecookie,
			@CookieValue(value = "languagecookie", required = false) String languagecookie) {

		String customeraccount = customer.getCustomeraccount();
		String customername = customer.getCustomername();
		String customeraddress = customer.getCustomeraddress();

		return opencccountservive.listallcustomer(opeorgcookie, opetypecookie, customeraccount, customername,
				customeraddress,languagecookie,"总");

	}
	
	// 列出所有可开户的分表用户
		@RequestMapping(value = "/list_can_openaccount_customer_child", method = RequestMethod.POST)
		public JsonResult<List<FileCustomer>> listallcustomer_child(@RequestBody Customer customer,
				@CookieValue(value = "opeorgcookie", required = false) String opeorgcookie,
				@CookieValue(value = "opetypecookie", required = false) String opetypecookie,
				@CookieValue(value = "languagecookie", required = false) String languagecookie) {

			String customeraccount = customer.getCustomeraccount();
			String customername = customer.getCustomername();
			String customeraddress = customer.getCustomeraddress();

			return opencccountservive.listallcustomer(opeorgcookie, opetypecookie, customeraccount, customername,
					customeraddress,languagecookie,"分");

		}

	// 开户操作
	@RequestMapping(value = "/open_account", method = RequestMethod.POST)
	public JsonResult<Recharge> openaccount(@RequestBody FileCustomer filecustomer,
			@CookieValue(value = "opecodecookie", required = false) String opecodecookie) {

		Integer customerid = filecustomer.getCustomerid();
		

		return opencccountservive.openaccount(customerid, opecodecookie);
	}

}
